from dataclasses import dataclass, field, asdict
from typing import Tuple

from Attriabte import Color


@dataclass
class BasicWidgetDto:
    """
    基础控件参数Dto
    """
    text: str = field(default="")
    bg: str = field(default=Color.default_bg)
    fg: str = field(default=Color.default_fg)
    font: Tuple[str] = field(default=("黑体", 12))

    def todict(self, ignore=[]) -> dict:
        widget_arg = list(asdict(BasicWidgetDto()).keys())
        for i in ignore:
            widget_arg.remove(i)
        return asdict(self, dict_factory=lambda x: {k: v for (k, v) in x if k in widget_arg})


@dataclass
class ColorHoverWidgetDto(BasicWidgetDto):
    """
    ColorHoverLabel DTO
    """

    hover_fg: str = field(default=Color.red)
    hover_bg: str = field(default=Color.default_bg)


@dataclass
class ImageHoverWidgetDto(BasicWidgetDto):
    """
    ImageHoverLabel DTO
    """
    hover_image: str = field(default="")
    default_image: str = field(default="")


@dataclass
class MoveAnimalDto:
    """
    The Animal to move DTO
    from_site: 初始位置
    to_site: 目的位置
    speed: 速度 (循环后休息时间)
    frame: 帧 动画持续的帧数
    """

    from_site: Tuple[int, int] = field(default=())
    to_site: Tuple[int, int] = field(default=())
    frame: int = field(default=20)
    speed: int = field(default=.02)


@dataclass
class LayoutDto:
    """
    Layout Dto
    """
    side_image_head: str = field(default="")  # 侧边栏图片资源名称 头部
    background: str = field(default="")  # 背景色
    side_image_foot: str = field(default="")  # 侧边栏图片资源名称 底部
    color_style: str = field(default="None")  # 配色方案
    hover_children: bool = field(default=False)  # 是否为 BasicWidgetDto 派生类

    """
    配色方案
    None: 默认 无配色方案
    Zebra: 条纹模式
    Single<Color>: 单一模式
    """


if __name__ == '__main__':
    wd = ColorHoverWidgetDto("we", hover_bg='red')
    print(list(asdict(wd).keys()))
